package org.tigr.htc.cmd;

/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

import org.apache.log4j.Logger;

/**
 * The <b>CommandStatus</b> class is a value object
 *
 */
public class CommandStatusImp {
    static private Logger log = Logger.getLogger(CommandStatusImp.class);
    protected String message;
    protected int returnValue;
    protected int errors;
    protected int waiting;
    protected int completed;
    protected int interrupted;
    protected int running;
    protected int id;

    /**
     * Creates a new <code>CommandStatus</code> instance.
     *
     */
    public CommandStatusImp() {
        message = "";
        errors = 0;
        waiting = 0;
        completed = 0;
        running = 0;
        returnValue = 0;
    }

    /**
     * This constructor creates a new instance.
     *  
     * @param message
     * @param returnValue
     * @param errors
     * @param waiting
     * @param completed
     * @param interrupted
     * @param running
     */
    public CommandStatusImp(String message, int returnValue, int errors,
            int waiting, int completed, int interrupted, int running) {
        super();
        this.message = message;
        this.returnValue = returnValue;
        this.errors = errors;
        this.waiting = waiting;
        this.completed = completed;
        this.interrupted = interrupted;
        this.running = running;
    }

    //
    //  Getters and Setters
    //
    
    /**
     * <code>getID</code> get command ID.
     * 
     * @return an <code>long</code> command id
     */
    public int getID() {
	log.debug(" status get id ->" + id);
	return this.id;
    }
    
    /**
     * <code>setID</code> set command ID.
     * 
     * @param p_id
     *            an <code>long</code> command id
     */
    public void setID(int p_id) {
	log.debug("status set id " + p_id);
	this.id = p_id;
    }

    /**
     * Describe <code>setMessage</code> method here.
     *
     * @param p_message a <code>String</code> value
     */
    public void setMessage(String p_message) {
	this.message = p_message;
    }

    /**
     * Describe <code>getMessage</code> method here.
     *
     * @return a <code>String</code> value
     */
    public String getMessage() {
	return this.message;
    }

    public void setReturnValue(int p_returnValue) {
	returnValue = p_returnValue;
    }

    /**
     * Describe <code>getReturnValue</code> method here.
     *
     * @return an <code>int</code> value
     */
    public int getReturnValue() {
	return this.returnValue;
    }

    /**
     * Describe <code>setErrors</code> method here.
     *
     * @param p_errors an <code>int</code> value
     */
    public void setErrors(int p_errors) {
	this.errors = p_errors;
    }

    /**
     * Describe <code>getErrors</code> method here.
     *
     * @return an <code>int</code> value
     */
    public int getErrors() {
	return this.errors;
    }

    /**
     * Describe <code>setWaiting</code> method here.
     *
     * @param p_waiting an <code>int</code> value
     */
    public void setWaiting(int p_waiting) {
	this.waiting = p_waiting;
    }

    /**
     * Describe <code>getWaiting</code> method here.
     *
     * @return an <code>int</code> value
     */
    public int getWaiting() {
	return this.waiting;
    }

    /**
     * Describe <code>setCompleted</code> method here.
     *
     * @param p_completed an <code>int</code> value
     */
    public void setCompleted(int p_completed) {
	this.completed = p_completed;
    }

    /**
     * Describe <code>incCompleted</code> method here.
     *
     * @param p_completed an <code>int</code> value
     */
    public synchronized void incCompleted(int p_inc) {
	this.completed += p_inc;
    }

    public synchronized void incRunning(int p_inc) {
	this.running += p_inc;
    }

    public synchronized void incErrors(int p_inc) {
	this.errors += p_inc;
    }

    public synchronized void incWaiting(int p_inc) {
	this.waiting += p_inc;
    }


    /**
     * Describe <code>getCompleted</code> method here.
     *
     * @return an <code>int</code> value
     */
    public int getCompleted() {
	return this.completed;
    }

    /**
     * Describe <code>setRunning</code> method here.
     *
     * @param p_running an <code>int</code> value
     */
    public void setRunning(int p_running) {
	this.running = p_running;
    }

    /**
     * Describe <code>getRunning</code> method here.
     *
     * @return an <code>int</code> value
     */
    public int getRunning() {
	return this.running;
    }

    public Object clone() {
        return new CommandStatusImp(message, returnValue, errors, waiting,
				    completed, interrupted, running);
    }
}
